package operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: wenxiwen
 * Date: 2022/4/13
 * Time: 17:32
 * Description: No Description
 */
public class Return implements IOperation{

    public void work(BookList booklist) {
        System.out.println("归还图书");


        System.out.println("请输入你要归还的书籍名称:");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        int dex = booklist.getCount();
        for (int i = 0; i < dex; i++) {
            Book book = booklist.getBook(i);
            if(name.equals(book.getName())) {
                if(book.isFly() != false) {
                    book.setFly(false);
                    System.out.println("归还成功！");
                    return;
                } else {
                    System.out.println("该书籍未借出");
                    return;
                }
            }
        }
        System.out.println("没有找到你要归还的书籍");
    }
}